raar.agent.process.sensor
Class RASensor

java.lang.Object
  extended by raar.agent.process.RAProcess
      extended by raar.agent.process.sensor.RASensor
All Implemented Interfaces:
java.io.Serializable, RAAgentDependentProcess
Direct Known Subclasses:
RACompass, RAExternalSensor, RAGripSensor, RALightSensor, RARegionSensor, RASensor_AgentIsExternal

public abstract class RASensor
extends RAProcess
implements java.io.Serializable, RAAgentDependentProcess

RASensor defines the sensors of an agent.

See Also:
Serialized Form

Field Summary
protected  RAAgent agent
          DO NOT CHANGE OR ACCESS; PROTECTED DUE TO IMPLEMENTATIONAL ISSUES.
 RADataType output
          DO NOT CHANGE OR ACCESS; PUBLIC DUE TO IMPLEMENTATIONAL ISSUES.
 java.lang.String outputName
          DO NOT CHANGE OR ACCESS; PUBLIC DUE TO IMPLEMENTATIONAL ISSUES.
 
Fields inherited from class raar.agent.process.RAProcess
hasRun, inregister, outregister, register, sourceCode, statement
 
Fields inherited from interface raar.agent.process.RAAgentDependentProcess
NO_AGENT_DEFINED
 
Constructor Summary
RASensor(java.lang.String outputName, RADataType outputType, RAAgent agent)
          Constructor.
 
Method Summary
 boolean acceptsInput(RADataType b, java.lang.String n)
          The sensor accepts no input at all.
 void dumpRegisters()
          Give a System.out dump of the current content.
 void execute()
          Executing the sensor is illegal and will produce an error.
abstract  java.lang.String explain()
          Give a String that explains what the sensor does.
 RADataType get(java.lang.String key)
          Get a specific key's value from the output register.
 RAAgent getAgent()
          Get sensor's agent.
 java.awt.Color getColor()
          Colour representation.
 RADataType getDataType(java.lang.String name)
          Returns the datatype for a given name.
 java.util.Vector getInputNames()
          A sensor does not have any inputs and will return null.
 java.util.Vector getInputObjects()
          A sensor does not have any inputs and will return null.
 java.util.Vector getOutputNames()
          Get a String vector containing the names of the keys the output register stores (in order).
 java.util.Vector getOutputObjects()
          Get an RADataType vector containing the current content of the output register.
 RADataType getSensorValue()
          Returns the RADataType currently stored in the sensor.
 boolean isSpecial()
          The sensor is a special process and will return true.
 void removeReferenceToAgent()
          Remove agent reference.
abstract  void run()
          Run the sensor (abstract).
 void set(java.lang.String key, RADataType value)
          Setting values from the outside is illegal and will produce an error.
 void setAgent(RAAgent a)
          Set sensor's agent.
protected  void setOutput()
          Recreate the output registers.
 void setReferenceToAgent(RAAgent a)
          Restore agent reference.
 void setSourceCode(java.lang.String code)
          Setting the process source code is illegal and will produce an error.
 boolean suppliesOutput(RADataType b, java.lang.String n)
          See whether the sensor supplies a certain output.
abstract  java.lang.String toString()
          String representation.
 
Methods inherited from class raar.agent.process.RAProcess
clone, getProcessName, getSourceCode, reset, setProcessName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

outputName

public java.lang.String outputName
DO NOT CHANGE OR ACCESS; PUBLIC DUE TO IMPLEMENTATIONAL ISSUES.


output

public RADataType output
DO NOT CHANGE OR ACCESS; PUBLIC DUE TO IMPLEMENTATIONAL ISSUES.


agent

protected transient RAAgent agent
DO NOT CHANGE OR ACCESS; PROTECTED DUE TO IMPLEMENTATIONAL ISSUES.

Constructor Detail

RASensor

public RASensor(java.lang.String outputName,
                RADataType outputType,
                RAAgent agent)
Constructor.

Method Detail

setSourceCode

public void setSourceCode(java.lang.String code)
                   throws RAException
Setting the process source code is illegal and will produce an error.

Overrides:
setSourceCode in class RAProcess
Throws:
RAException

execute

public void execute()
             throws RAException
Executing the sensor is illegal and will produce an error.

Overrides:
execute in class RAProcess
Throws:
RAException

run

public abstract void run()
                  throws RAException
Run the sensor (abstract).

Overrides:
run in class RAProcess
Throws:
RAException

dumpRegisters

public void dumpRegisters()
Give a System.out dump of the current content.

Overrides:
dumpRegisters in class RAProcess

set

public void set(java.lang.String key,
                RADataType value)
         throws RAException
Setting values from the outside is illegal and will produce an error.

Overrides:
set in class RAProcess
Throws:
RAException

get

public RADataType get(java.lang.String key)
               throws RAException
Get a specific key's value from the output register. Overridden; does work when you use the output name as your key. Will throw an exception otherwise (just as the normal processes).

Overrides:
get in class RAProcess
Throws:
RAException

getDataType

public RADataType getDataType(java.lang.String name)
                       throws RAException
Returns the datatype for a given name. Necessary for making healthy connections. The output of the sensor is no fixed type, so a (general) RADataType is returned.

Overrides:
getDataType in class RAProcess
Throws:
RAException

getOutputNames

public java.util.Vector getOutputNames()
Get a String vector containing the names of the keys the output register stores (in order). This shows a user which outputs a process has (by name).

Overrides:
getOutputNames in class RAProcess

getOutputObjects

public java.util.Vector getOutputObjects()
Get an RADataType vector containing the current content of the output register. Rather than manipulating this content in a sneaky way now, you should use this feature to determine the datatypes of the content. This enables checking whether certain connections are allowed between (various) processes' out- and input.

Overrides:
getOutputObjects in class RAProcess

getInputNames

public java.util.Vector getInputNames()
A sensor does not have any inputs and will return null.

Overrides:
getInputNames in class RAProcess

getInputObjects

public java.util.Vector getInputObjects()
A sensor does not have any inputs and will return null.

Overrides:
getInputObjects in class RAProcess

getSensorValue

public RADataType getSensorValue()
Returns the RADataType currently stored in the sensor.


isSpecial

public boolean isSpecial()
The sensor is a special process and will return true.

Overrides:
isSpecial in class RAProcess

setOutput

protected void setOutput()
Recreate the output registers.


setAgent

public void setAgent(RAAgent a)
Set sensor's agent.


getAgent

public RAAgent getAgent()
Get sensor's agent.


acceptsInput

public boolean acceptsInput(RADataType b,
                            java.lang.String n)
The sensor accepts no input at all.

Overrides:
acceptsInput in class RAProcess

suppliesOutput

public boolean suppliesOutput(RADataType b,
                              java.lang.String n)
See whether the sensor supplies a certain output.

Overrides:
suppliesOutput in class RAProcess

toString

public abstract java.lang.String toString()
String representation.

Overrides:
toString in class java.lang.Object

explain

public abstract java.lang.String explain()
Give a String that explains what the sensor does.


getColor

public java.awt.Color getColor()
Colour representation.


removeReferenceToAgent

public void removeReferenceToAgent()
Remove agent reference.

Specified by:
removeReferenceToAgent in interface RAAgentDependentProcess

setReferenceToAgent

public void setReferenceToAgent(RAAgent a)
Restore agent reference.

Specified by:
setReferenceToAgent in interface RAAgentDependentProcess